﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.WeixinMP.Interfaces;
using Microhard.WeixinMP.Unities;
using Microhard.WeixinMP.Models;
using System.Configuration;

namespace Microhard.WeixinMP.Impls
{
    public class FeedbackWXHandler : BaseResponseImpl
    {
        public override Interfaces.WeixinCommand Command
        {
            get
            {
                WeixinCommand cmm = new WeixinCommand();
                cmm.Event = "CLICK";
                cmm.EventKey = "feedback";
                return cmm;
            }
        }

        protected override Models.WeixinBaseData<object> CreateFeatureResponse(Models.RequestServiceModel request, Models.WeixinBaseData<object> response)
        {
            //创建token
            string token = SessionSecurity.CreateToken(response.ToUserName);

            //创建会话成功，发起服务
            response.MsgType = WeixinMsgType.Text;
            response.FuncFlag = WeixinMsgType.FuncFlag_False;

            //生成链接地址
            string feedbackUrl = ConfigurationManager.AppSettings["FeedbackUrl"];
            string finUrl = string.Format(this.UrlFormat, feedbackUrl, token, response.EncodeWeixinToUserName, string.Empty, request.ConversationID);
            WeixinTxt result = new WeixinTxt();
            result.Content = ConfigurationManager.AppSettings["feedbackMsg"] +
                ",也可以<a href='" + finUrl + "'>请点击这里</a>提交您的投诉，感谢您的支持。";

            response.Content = result;
            return response;
        }
    }
}
